/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package JGameAdapter;

/**
 *
 * @author markusbaisch
 */
public class Pedal
{
    // aktueller Wert
    private double current;

    // Anzahl der Schritte
    private double maximum;
    private double perStep;

    public Pedal(double maximum, double perStep, double init)
    {
        current = init;
        this.maximum = maximum;
        this.perStep = perStep;
    }

    public void step(boolean keypressed)
    {
        // Taste wurde gedrückt
        if(keypressed)
        {
            if(maximum > current)
            {
                current +=perStep;
            }
            else
                current = maximum;
        }
        else
        {
            if(current > 0)
            {
                current -=perStep;
            }
            else current = 0;
        }
    }

    public double value()
    {
        return current;
    }
}
